<template>
  <div class="about">
    <div class="swiper-container">
      <div class="swiper-wrapper">
        <div class="swiper-slide" v-for="item in arrnew" :key="item" :style="{backgroundImage: 'url(' + fz(item.pic) + ')', backgroundSize:'100% 100%'}"></div>
      </div>
       
      <!-- 如果需要分页器 -->
      <div class="swiper-pagination"></div>

      <!-- 如果需要导航按钮 -->
      <div class="swiper-button-prev"></div>
      <div class="swiper-button-next"></div>

      <!-- 如果需要滚动条 -->
      <!--    <div class="swiper-scrollbar"></div>-->
    </div>
  </div>
</template>

<script>
// import Swiper from 'swiper'
export default {
  name: "About",
  data() {
    return {
        arr: [],
      arrnew: [],
      title: [],
      index:""
    };
  },
  methods:{
    fz(str) {
      return "http://jd.itying.com/" + str.split("\\").join("/");
    },
  },
  mounted() {
     this.axios.get("https://jd.itying.com/api/focus").then((res) => {
      this.arr = res.data.result;
      this.arrnew = this.arr.splice(0, 4);
    });
    this.axios.get("https://jd.itying.com/api/pcate").then((res) => {
      this.title = res.data.result;
    });
    this.axios.get("https://jd.itying.com/api/plist?cid="+this.index).then((res) => {
      console.log(res);
    });
    new Swiper(".swiper-container", {
      loop: true,
      // 如果需要分页器
      pagination: ".swiper-pagination",
      // 如果需要前进后退按钮
      nextButton: ".swiper-button-next",
      prevButton: ".swiper-button-prev",
      // 如果需要滚动条
      // scrollbar: '.swiper-scrollbar',
      //如果需要自动切换海报
      autoplay: {
        delay: 1000,//时间 毫秒
        disableOnInteraction: false,//用户操作之后是否停止自动轮播默认true
      },
    });
  },
};
</script>

<style lang="css" scoped>
.swiper-container {
  height: 500px;
  width: 100%;
}
.swiper-wrapper {
  width: 100%;
  height: 100%;
}
.swiper-slide {
  width: 100%;
  height: 100%;
  background-color: #42b983;
  text-align: center;
  line-height: 500px;
}
</style>